<%@CODEPAGE="65001"%>
<!--#include file="../Include/Conn.asp" -->
<!--#include file="../Include/Function.asp" -->
<!--#include file="seeion.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>单页管理</title>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<link href="images/style.css" type=text/css rel=stylesheet>
<SCRIPT>
function CheckAll(theForm){ 
 for (var i=0;i<eval(theForm.elements.length);i++){ 
  var e=theForm.elements[i]; 
  if (e.name!="allbox") e.checked=theForm.allbox.checked; 
 } 
} 
</SCRIPT>
<body>
<form name="" action="" method="post">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#cccccc">
  <tr>
    <td height="30" class="topnav"><div>单页管理</div></td>
  </tr>
  <tr>
    <td bgcolor="#ffffff">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
      
      <tr>
        <td  bgcolor="#ffffff">
  <table width="100%" border=0 align=center cellpadding=3 cellspacing=0 class="stable">
<thead>
      <tr bgcolor="#eeeeee">
        <td width=53 align="center" class=td>选择</td>
        <td width=52 align="center" class=td>编号</td>
        <td width=101 align="center" class=td>类型</td>
        <td height=33 align="center" colspan="2" class=td>栏目名称</td>
        <td width=101 align="center" class=td>模板</td>
        <td width=187 align="center" class=td>链接</td>
        <td width=88 align="center" class=td>排序</td>
        <td width=89 align="center" class=td>状态</td>
        <td width=212 align="center" class=td>操作</td>
        </tr></thead>
	<%aboutlist%>
    <tr>
        <td align="center"><input onClick="CheckAll(this.form)" type="checkbox" value="1" name="allbox"></td>
        <td>全选</td>
        <td colspan="8">
            <input class="btn" type="submit" value="删 除" onClick="if(confirm('确定要删除吗')){form.action='?action=del';}else{return false};"/>  
            <input class="btn" type="submit" value="禁 用" onClick="form.action='?action=off';"./>
            <input class="btn" type="submit" value="启 用" onClick="form.action='?action=on';"/>
            <input class="btn" type="submit" value="保 存" onClick="form.action='admin_class.asp?action=saveall';"/></td>
        </tr>
   </table>
   </td>
     </tr>
    </table></td>
  </tr>
</table>
</form>
<%call footer%>
</body>
</html>
<%
dim action : action=getForm("action","get")
Select case action	
	case "edit" :editSort	
	case "del" : delSort
	case "on" : onOff "on", "zych_Type", "SortID", "isok", "", getPageName()
	case "off" : onOff "off", "zych_Type", "SortID", "isok", "", getPageName()
End Select

dim SortID, ParentID, px_id, SortType, SortName, SortURL, SortLevel, AddTime, PageTitle, PageKeywords, PageDesc, SortPath, isok, TopSortID, GroupID, Exclusive, Content
dim sql, msg

Sub getSort
	dim id : id=getForm("id","get")
	if not isnul(ID) then		
		set rs=server.createobject("adodb.recordset") 
        exec="select * from zych_Type where SortID="&ID
        rs.open exec,conn,1,1
		if rs.eof then 
			alertMsgAndGo "没有这条记录","-1"
		else
			SortID=rs("SortID")
			ParentID=rs("ParentID")
			px_id=rs("px_id")
			SortType=rs("SortType")
			SortName=rs("SortName")
			SortURL=rs("SortURL")
			SortLevel=rs("SortLevel")
			AddTime=rs("AddTime")
			PageTitle=rs("PageTitle")
			PageKeywords=rs("PageKeywords")
			PageDesc=rs("PageDesc")
			SortPath=rs("SortPath")
			isok=rs("isok")
			TopSortID=rs("TopSortID")
			Content=rs("SortContent")
		end if
		rs.close : set rs=nothing
	else		
		alertMsgAndGo "没有这条记录","-1"
	end if 
End Sub

Sub aboutList
        set rs=server.createobject("adodb.recordset") 
        exec="select * from zych_Type where SortType=1 Order by px_id Asc,SortID"
        rs.open exec,conn,1,1
	If rs.Eof Then 
		echo"<tr bgcolor=""#FFFFFF"" align=""center"">"&vbcrlf& _
			"<td colspan=""5"">暂无数据</td>"&vbcrlf& _
		  "</tr>"&vbcrlf
	Else
		Do while not rs.Eof 
			if rs("ParentID")<>0 then align="style=""width:40px;text-align:right""" else align="style=""width:40px"""
			if rs("Sortimg")<>"" then Sortimg="<img src="""&rs("Sortimg")&""" width=130 height=30 />" else Sortimg=""
			echo "<tr bgcolor=""#ffffff"" align=""center"" onMouseOver=""this.bgColor='#EEEEEE'"" onMouseOut=""this.bgColor='#ffffff'"">"&vbcrlf
			echo "<td height=""28"" class=""td""><input type=""checkbox"" name=""id"" class=""inp"" value="""&rs("SortID")&"""/><input type=""hidden"" name=""SortIDs"" class=""inp"" value="""&rs("SortID")&""" /></td>"&vbcrlf
			echo "<td class=""td""><input type=""text"" class=""inp"" style=""text-align:center;width:40px"" value="""&rs("SortID")&""" readonly/></td>"&vbcrlf
			echo "<td class=""td"">"&sortTypenames(rs("SortType"))&"</td>"&vbcrlf
			echo "<td align=""left"" class=""td"">"&getLevel(rs("SortLevel"))&"<input name=""SortNames"" type=""text"" class=""inp"" id=""SortNames"" value="""&rs("SortName")&""" maxlength=""200"" style=""width:120px;"" class=""btn1""/>-<input name=""Sorthtml"" type=""text""  id=""Sorthtml"" class=""inp"" value="""&rs("Sorthtml")&"""  maxlength=""255"" style=""width:115px;"" class=""btn1""/></td>"&vbcrlf
			echo "<td class=""td"">"&Sortimg&"</td>"&vbcrlf
			echo "<td class=""td"">"&rs("Temp")&"</td>"&vbcrlf
			echo "<td class=""td""><input name=""SortUrls"" type=""text"" class=""inp""  id=""SortUrls"" value="""&rs("SortUrl")&""" size=""18"" maxlength=""255""/></td>"&vbcrlf
			echo "<td class=""td"">"
			echo "<input name=""px_ids"" type=""text"" "&align&"  class=""inp"" id=""px_id"" value="""&rs("px_id")&""" size=""3"" maxlength=""4""/>"
			echo "</td>"&vbcrlf
			echo "<TD class=""td"">"&getStr(rs("isok"),"<a href=""?action=off&id="&rs("SortID")&""" title=""启用"" ><IMG src=""images/toolbar_ok.gif""></a>","<a href=""?action=on&id="&rs("SortID")&""" title=""禁用"" ><IMG src=""images/toolbar_no.gif""></a>")&"</TD>"&vbcrlf
			echo "<td class=""td""><input type=""button"" name=""Submit3"" value=""添加子类"" onClick=""window.location.href='add_Class.asp?id="&rs("Sortid")&"'""  class=""btn""/> <input type=""button"" name=""Submit3"" value=""修 改"" onClick=""window.location.href='Edit_About.asp?id="&rs("Sortid")&"'""  class=""btn""/> <input type=""button"" name=""Submit"" value=""删 除"" onClick=""javascript:if(confirm('确定删除？删除后不可恢复!')){window.location.href='?action=del&id="&rs("Sortid")&"';}else{history.go(0);}""  class=""btn""/></td>"&vbcrlf			
			echo "</tr>"&vbcrlf
		  rs.MoveNext
		Loop
	End If
	rs.close	:	Set rs = nothing
End Sub

Sub editSort	
	SortID=getForm("SortID", "post")
	SortName=getForm("SortName", "post")
	PageTitle=getForm("PageTitle", "post")
	PageKeywords=getForm("PageKeywords", "post")
	PageDesc=getForm("PageDesc", "post")	
	isok=getForm("isok", "post")
	Content=Trim(Request.Form("Content"))
	if isnul(SortName) then alertMsgAndGo "分类名称不能为空","-1"	
	conn.exec "update zych_Type set SortName='"&SortName&"', PageTitle='"&PageTitle&"', PageKeywords='"&PageKeywords&"', PageDesc='"&PageDesc&"', SortContent='"&Content&"' where SortID="&SortID, "exe"	
	alertMsgAndGo "修改成功","About.asp"
End Sub
Sub saveAll
	if key<>0 and  instr(manage,"|11")=0 then
		Call adminJump("Sorry!","您没有管理该模块的权限！","javascript:window.history.go(-1)")
		response.End
	End if
	Dim ids				:	ids=split(getForm("SortIDs","post"),",")
	Dim SortNames		:	SortNames=split(getForm("SortNames","post"),",")
	Dim Sorthtmls		:	Sorthtmls=split(getForm("Sorthtml","post"),",")
	Dim SortURLs		:	SortURLs=split(getForm("SortURLs","post"),",")
	Dim px_ids		:	px_ids=split(getForm("px_ids","post"),",")
	If Ubound(ids)=-1 Then 	'防止有值为空时下标越界
		ReDim ids(0)
		ids(0)=""
	End If	
	If Ubound(SortNames)=-1 Then
		ReDim SortNames(0)
		SortNames(0)=""
	End If
	If Ubound(Sorthtmls)=-1 Then
		ReDim Sorthtmls(0)
		Sorthtmls(0)=""
	End If
	If Ubound(SortURLs)=-1 Then
		ReDim SortURLs(0)
		SortURLs(0)=""
	End If

	If Ubound(px_ids)=-1 Then
		ReDim px_ids(0)
		px_ids(0)=0
	End If
	Dim i
	For i=0 To Ubound(ids)		
		if not isnum(px_ids(i))  then px_ids(i)=0
		conn.execute "update zych_Type Set SortName='"&trim(SortNames(i))&"',Sorthtml='"&trim(Sorthtmls(i))&"',SortURL='"&trim(SortURLs(i))&"',px_id='"&trim(px_ids(i))&"' Where SortID="&trim(ids(i)),"exe"

	Next
	alertMsgAndGo "保存成功","admin_about.asp"
End Sub	
Sub delSort
	if key<>0 and  instr(manage,"|11")=0 then
		Call adminJump("Sorry!","您没有管理该模块的权限！","javascript:window.history.go(-1)")
		response.End
	End if
	dim id :id=getForm("id","both")
	if isnul(id) then alertMsgAndGo "请选择要操作的内容","-1"
	dim ids,i
	ids=split(id,",")
	for i=0 to ubound(ids)
		if not isnul(ids(i)) then 
			dim subids : subids=getSubSort(ids(i), 1)
			dim subid : subid=split(subids,",")
			dim j
			if runmode=1 then
				for j=0 to ubound(subid)
					delList(trim(subid(j)))
				next
				dim rs, sql, filepath
				dim templateobj : set templateobj=new TemplateClass
				sql="select * from Content where SortID in ("&subids&")"
				sql="select Cid,Title,sortType,SortFolder,a.GroupID,a.AddTime,PageFileName,a.SortID,b.GroupID from Content as a, zych_Type as b where a.SortID=b.SortID and b.SortID in ("&subids&")"
				set rs=conn.execute(sql,"r1")		
				do while not rs.eof
					filepath=templateobj.getContentLink(rs("SortID"),rs("Cid"),rs("SortFolder"),rs("a.GroupID"),rs("AddTime"),rs("PageFileName"),rs("b.GroupID"))
					if isExistFile(filepath) then delFile filepath
					
					rs.movenext
				loop
			end if
			conn.execute"delete * from Content where SortID in ("&subids&")","exe"
			conn.execute"delete * from [zych_Type] where SortID in ("&subids&")","exe"
			'通过栏目ID获取字段列表后，通过字段名称逐一删除文章列表中的字段
			Dim rsObj:Set rsObj=conn.execute("select * from FieldSet where Fieldfl in ("&subids&") Order by FieldOrder Asc,FieldID","r1")
			If  rsObj.Eof Then 
				echo ""
			Else
			Do while not rsObj.Eof
				conn.execute("alter table Content drop column "&rsObj("Field_title"))
			rsObj.movenext
			Loop	
			end if
			rsObj.close:Set rsObj = nothing
			'以上结束，以下为同步删除字段表中的字段
			conn.execute"delete * from [FieldSet] where FieldFL in ("&subids&")","exe"
		end if
	next
	alertMsgAndGo "删除成功！",getPageName()		
End Sub
%>